package main

import (
	"fmt"
	"reflect"
)

func main() {
	s := "测试一下字符串"
	subStr := "字符"
	fmt.Println(MyIndex(s, subStr))
}

func MyIndex(s string, subs string) int {
	rs := []rune(s)
	subrs := []rune(subs)

	sliceR := reflect.ValueOf(rs)
	subSliceR := reflect.ValueOf(subrs)

	for i := 0; i <= sliceR.Len()-subSliceR.Len(); i++ {
		if reflect.DeepEqual(sliceR.Slice(i, i+subSliceR.Len()).Interface(), subSliceR.Interface()) {
			return i
		}
	}
	return -1
}
